Conversation
Co-authored-by: chris <chris@knock.app>
|
Cursor Agent can help with this pull request. Just |
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: chris <chris@knock.app>
This change ensures that the Knock client is always instantiated, but authentication is conditionally applied based on the `enabled` prop. This simplifies the provider's logic and allows child providers to function even when Knock is disabled. Co-authored-by: chris <chris@knock.app>
Co-authored-by: chris <chris@knock.app>
Co-authored-by: chris <chris@knock.app>
This commit refactors the logging within the feed client to ensure consistency and improves the authentication logic in the Knock client and KnockProvider. Co-authored-by: chris <chris@knock.app>
Co-authored-by: chris <chris@knock.app>
Co-authored-by: chris <chris@knock.app>
Co-authored-by: chris <chris@knock.app>
|
@cursor review |
This commit adds checks to ensure that client methods are only called when the user is authenticated. If the user is not authenticated, the method will log a message and return early, preventing unnecessary API calls. Co-authored-by: chris <chris@knock.app>
Co-authored-by: chris <chris@knock.app>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #820 +/- ##
==========================================
+ Coverage 67.31% 67.73% +0.41%
==========================================
Files 189 189
Lines 7930 8144 +214
Branches 1024 1095 +71
==========================================
+ Hits 5338 5516 +178
- Misses 2567 2603 +36
Partials 25 25
|
Description
Adds an
enabledprop toKnockProviderto control whether the provider should authenticate and initialize the Knock client.This change addresses the problem where
KnockProviderwould always attempt authentication on mount, even withundefineduserId/userToken, leading to boilerplate conditional rendering or auth errors.The
enabledprop (defaulting totrue) allows users to conditionally skip authentication by settingenabled={false}, similar to patterns in other popular React libraries. This removes the need for wrapper components and prevents unnecessary API calls in unauthenticated states.The implementation refactors
KnockProviderinto two components: an outerKnockProviderhandling theenabledlogic and an innerAuthenticatedKnockProviderresponsible for the actual client initialization and authentication. This ensures React hook rules are followed while providing the desired functionality.Checklist
Linear Issue: KNO-10561